import { defineStore } from 'pinia'

export const useToastStore = defineStore('toast', {
  state: () => {
    return {
      trigger: false,
      config: {
        severity: 'success',
        summary: 'Success',
        detail: 'Data Uploaded',
        life: 3000,
        group: 'upload_success'
      },
      closeTrigger: false,
      closeGroup: 'upload_success'
    }
  },
  actions: {
    showToast(config) {
      this.trigger = !this.trigger
      this.config = { ...this.config, ...config }
    },
    closeToastGroup(group) {
      this.closeTrigger = !this.closeTrigger
      this.closeGroup = group
    }
  }
})
